home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
6
/
cl0588.zip
/
GETOP.C
< prev
next >
Wrap
Text File
|
1988-01-21
|
777b
|
39 lines
/* .subt |Get operation type for desktop calculator */
getop(s,lim)
char s[];
int lim;
{
int i, c;
while ((c = getch()) == ' ' || c == '\t' || c == '\n')
;
if (c != '.' && (c < '0' || c > '9'))
return(c);
s[0] = c;
for (i = 1; (c = getchar()) >= '0' && c <= '9'; i++)
if (i < lim)
s[i] = c;
if (c == '.') {
if (i < lim)
s[i] = c;
for (i++; (c = getchar()) >= '0' && c <= '9'; i++)
if (i<lim)
s[i] = c;
}
if (i < lim) {
ungetch(c);
s[i] = '\0';
return(NUMBER);
}
else {
while (c != '\n' && c != EOF)
c = getchar();
s[lim-1] = '\0';
return(TOOBIG);
}
}
/* .subt < end of file, file getop.c */